package com.it.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.it.domain.Brand;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * 业务层快速开发测试  ctrl+shift+t 快速创建测试类
 */

@SpringBootTest
class BrandServiceTestCase {
    @Autowired
    private IBrandService brandService;
    @Test
    void add() {
        Brand brand = new Brand();
        brand.setBrandName("鸿星尔克123");
        brand.setCompanyName("鸿星尔克123");
        brand.setOrdered(21);
        brand.setDescription("飞一般的感觉");
        brand.setStatus(0);
        brandService.save(brand);
    }

    @Test
    void delete() {
        brandService.removeById(6);
    }

    @Test
    void update() {
        Brand brand = new Brand();
        brand.setId(2);
        brand.setBrandName("as");
        brand.setCompanyName("asd");
        brand.setOrdered(12);
        brand.setDescription("飞一般的感觉");
        brand.setStatus(1);
        brandService.updateById(brand);

    }

    @Test
    void selectById() {
        System.out.println(brandService.getById(2));
    }

    @Test
    void selectAll() {
        brandService.list();
    }

    @Test
    void testSelectByPage() {   //第几页 ， 每页条数
        IPage<Brand> page = new Page<>(1, 5) ;
        brandService.page(page);
        System.out.println("当前页码：" + page.getCurrent());
        System.out.println("每页显示数：" + page.getSize());
        System.out.println("一共多少页：" + page.getPages());     //Total/size
        System.out.println("一共多少条数据：" + page.getTotal()); //count*
        System.out.println("数据：" + page.getRecords());     //当前页数据
    }

}